package com.youbug.kefu.config;

import com.youbug.kefu.exception.NoLoginException;
import com.youbug.kefu.vo.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class MyExceptionHandler {

    @ExceptionHandler(RuntimeException.class)
    public R<String> RuntimeExceptionHanlder(RuntimeException e){

        log.error(e.getMessage(),e);

        return R.fail(e.getMessage());
    }

    @ExceptionHandler(NoLoginException.class)
    public R<String> NoLoginExceptionHanlder(NoLoginException e){

        log.error(e.getMessage(),e);

        return R.fail(e.getMessage());
    }
}
